package com.zhuhao.basic.classload;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Author zhuhao
 * @Date 2022/5/27 9:57
 * @desc
 */
public class ClassLoaderDemo {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, InterruptedException {
        Class<?> clazz = Class.forName("com.zhuhao.basic.classload.Test001");
//        Class<Test001> clazz = Test001.class;
//        Class<? extends Test001> clazz = new Test001().getClass();

        Object newInstance = clazz.getConstructor().newInstance();
        Test001 test001 = (Test001) newInstance;
//        test001.tellMe();

        Method method = newInstance.getClass().getDeclaredMethod("tellMe");
        method.setAccessible(true);
        method.invoke(newInstance);

    }
}
